﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SchoolInfoDetail.aspx.cs" Inherits="WebPage_SchoolInfoDetail" %>

<%@ Register Src="~/UserControl/NotNullAndNunber.ascx" TagName="NotNullAndNunber"
    TagPrefix="uc1" %>
<%@ Register Src="~/UserControl/Number.ascx" TagName="Number" TagPrefix="uc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>信息详情</title>
    <link href="../CSS/css.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
    function doaction(_index,_judge)
    {
        if(_index==1)  //新建
        {
            if(_judge==1)
                return true;
            else
                alert("对不起，您没有权限新建信息！");
        }
        if(_index==2)  //修改
        {
            if(_judge==1)
                return true;
            else
                alert("对不起，您没有权限修改信息！");
        }
        if(_index==3)  //删除
        {
            if(_judge==1)
                {
                    if(window.confirm("确定删除数据？"))
                        return true;
                }
            else
                alert("对不起，您没有权限删除信息！");
        }     
        return false;   
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    
       <div id="MainContent" style="width:410px">
    <asp:Panel ID ="Pl1" runat="server" Width="100%">  
        <div class="tit" id="mcTitle" >校园信息</div> 
        <div class="con">        
        <table border="0" cellpadding="0" cellspacing="0" style="width: 410px">
                    <tr>
                        <td rowspan="1" style="width: 300px; text-align: left; height: 383px;">
                            <asp:DetailsView ID="DV_SCHOOLINFO" runat="server" AutoGenerateRows="False" 
                                CellPadding="4" DataKeyNames="TabSchID" DataSourceID="SDS_SCHOOLINFO" 
                                ForeColor="#333333" GridLines="None" Height="50px" Width="93%">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                <Fields>
                                    <asp:TemplateField HeaderText="ID" SortExpression="TabSchID">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label15" runat="server" Text='<%# Bind("TabSchID") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:Label ID="Label16" runat="server" Text='<%# Bind("TabSchID") %>'></asp:Label>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("TabSchID") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="学校名称" SortExpression="SchName">
                                        <EditItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("SchName") %>' 
                                                Width="150px"></asp:Label>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:Label ID="Label17" runat="server" Text='<%# Bind("SchName") %>' 
                                                Width="150px"></asp:Label>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("SchName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="主楼" SortExpression="MainOrDivsion">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("MainOrDivsion") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("MainOrDivsion") %>'></asp:TextBox>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label7" runat="server" Text='<%# Bind("MainOrDivsion") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="位置" SortExpression="SchLocation">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("SchLocation") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("SchLocation") %>'></asp:TextBox>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label9" runat="server" Text='<%# Bind("SchLocation") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="地址" SortExpression="SchAddress">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("SchAddress") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("SchAddress") %>'></asp:TextBox>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label9" runat="server" Text='<%# Bind("SchAddress") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="新生数量" SortExpression="NewStuNum">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("NewStuNum") %>'></asp:TextBox>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator91" 
                                                runat="server" ControlToValidate="TextBox9" Display="Dynamic" 
                                                ErrorMessage="请输入数字类型" ValidationExpression="^\d+(\.\d+)?$"></asp:RegularExpressionValidator>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("NewStuNum") %>'></asp:TextBox>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator92" 
                                                runat="server" ControlToValidate="TextBox10" Display="Dynamic" 
                                                ErrorMessage="请输入数字类型" ValidationExpression="^\d+(\.\d+)?$"></asp:RegularExpressionValidator>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label10" runat="server" Text='<%# Bind("NewStuNum") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="学生总数" SortExpression="TotalStuNum">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("TotalStuNum") %>'></asp:TextBox>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator101" 
                                                runat="server" ControlToValidate="TextBox10" Display="Dynamic" 
                                                ErrorMessage="请输入数字类型" ValidationExpression="^\d+(\.\d+)?$"></asp:RegularExpressionValidator>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("TotalStuNum") %>'></asp:TextBox>
                                            <asp:RegularExpressionValidator ID="RegularExpressionValidator102" 
                                                runat="server" ControlToValidate="TextBox11" Display="Dynamic" 
                                                ErrorMessage="请输入数字类型" ValidationExpression="^\d+(\.\d+)?$"></asp:RegularExpressionValidator>
                                        </InsertItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label11" runat="server" Text='<%# Bind("TotalStuNum") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField ShowHeader="False">
                                        <EditItemTemplate>
                                            <table style="width:100;">
                                                <tr>
                                                    <td>
                                                        <div onclick="return confirm('确定更新数据？')" style="text-align: center">
                                                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                                                                CommandName="Update" Text="更新"></asp:LinkButton>
                                                            &nbsp;</div>
                                                    </td>
                                                    <td>
                                                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                                            CommandName="Cancel" Text="取消"></asp:LinkButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <table style="width:100;">
                                                <tr>
                                                    <td>
                                                        <div onclick="return doaction(2,<%=_mod %>);">
                                                            <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                                                CommandName="Edit" Text="编辑"></asp:LinkButton>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div onclick="return doaction(3,<%=_del %>);">
                                                            <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" 
                                                                CommandName="Delete" Text="删除"></asp:LinkButton>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:TemplateField>
                                    <asp:TemplateField ShowHeader="False">
                                        <ItemTemplate>
                                            <asp:Button ID="btn_Back" runat="server" CausesValidation="False" 
                                                CssClass="buttonface" OnClick="btn_Back_Click" Text="返 回" Width="48px" />
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" />
                                    </asp:TemplateField>
                                </Fields>
                            </asp:DetailsView>
          </td>
                    </tr>
                </table>
                
               <%-- 注意下面如果有别名的话，如 select a.SchName from tab a,  那么要变成：select a.SchName as SchName from tab a--%>
        <asp:SqlDataSource ID="SDS_SCHOOLINFO" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand='DELETE FROM TAB_SCHOOLINFO WHERE TabSchID = :TabSchID' 
        InsertCommand='INSERT INTO TAB_SCHOOLINFO(SchName, MainOrDivsion, SchLocation, SchAddress, NewStuNum, TotalStuNum VALUES (:SchName, :MainOrDivsion, :SchLocation, :SchAddress, :NewStuNum, :TotalStuNum)' ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
        SelectCommand='SELECT TabSchID, SchName, MainOrDivsion, SchLocation,SchAddress, NewStuNum, TotalStuNum FROM TAB_SCHOOLINFO WHERE (TabSchID = 3)' 
        UpdateCommand='UPDATE TAB_SCHOOLINFO SET SchName = :SchName, MainOrDivsion=:MainOrDivsion,  SchLocation = :SchLocation,SchAddress = :SchAddress,TotalStuNum = :TotalStuNum WHERE (TabSchID = :TabSchID)' 
        OnDeleted="Sds_Deleted" 
        OnUpdated="Sds_Updated">
            <DeleteParameters>
                <asp:Parameter Name="TabSchID" Type="Decimal" />                
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="SchName" Type="String" />
                <asp:Parameter Name="MainOrDivsion" Type="String" />
                <asp:Parameter Name="SchLocation" Type="String" />
                <asp:Parameter Name="SchAddress" Type="String" />
                <asp:Parameter Name="NewStuNum" Type="Decimal" />
                <asp:Parameter Name="TotalStuNum" Type="Decimal" />               
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="SchName" Type="String" />
                <asp:Parameter Name="MainOrDivsion" Type="String" />
                <asp:Parameter Name="SchLocation" Type="String" />
                <asp:Parameter Name="SchAddress" Type="String" />
                <asp:Parameter Name="NewStuNum" Type="Decimal" />
                <asp:Parameter Name="TotalStuNum" Type="Decimal" />
            </InsertParameters>
            <SelectParameters>
           <%-- 下面也可以用sessionParameter--%>
                <asp:QueryStringParameter Name="TabSchID" QueryStringField="TabSchID" />
            </SelectParameters>
        </asp:SqlDataSource>
        </div>
        
    </asp:Panel>
    
    
    </div>
      
    </form>
</body>
</html>
